home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / misc / amicvs1-0.lha / AmiCVS / scr / cvs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-27  |  13.8 KB  |  441 lines

  1. /* @(#)cvs.h 1.72 92/03/31     */
  2.  
  3. #include "../lib/system.h"
  4. #include <stdio.h>
  5. #include <ctype.h>
  6. #include <pwd.h>
  7. #include <signal.h>
  8. #include "hash.h"
  9. #include "rcs.h"
  10. #include "../lib/regex.h"
  11. #include "../lib/fnmatch.h"
  12. #include "../lib/getopt.h"
  13. #include "wait.h"
  14. #include "config.h"
  15. #ifdef MY_NDBM
  16. #include "myndbm.h"
  17. #else
  18. #include <ndbm.h>
  19. #endif                /* !MY_NDBM */
  20.  
  21. /* XXX - for now this is static */
  22. /* [rbn]
  23. #undef PATH_MAX
  24. #ifdef MAXPATHLEN
  25. #define    PATH_MAX MAXPATHLEN+2
  26. #else
  27. #define    PATH_MAX 1024+2
  28. #endif
  29. */
  30.  
  31. /* just in case this implementation does not define this */
  32. #ifndef L_tmpnam
  33. #define    L_tmpnam    50
  34. #endif
  35.  
  36. #if __STDC__
  37. #define    CONST    const
  38. #define    PTR    void *
  39. #else
  40. #define    CONST
  41. #define    PTR    char *
  42. #endif
  43.  
  44. /*
  45.  * Copyright (c) 1992, Brian Berliner and Jeff Polk
  46.  * Copyright (c) 1989-1992, Brian Berliner
  47.  * 
  48.  * You may distribute under the terms of the GNU General Public License as
  49.  * specified in the README file that comes with the CVS 1.3 kit.
  50.  * 
  51.  * Definitions for the CVS Administrative directory and the files it contains.
  52.  * Here as #define's to make changing the names a simple task.
  53.  */
  54. #define    CVSADM        "CVS"
  55. #define    CVSADM_ENT    "CVS/Entries"
  56. #define    CVSADM_ENTBAK    "CVS/Entries.Backup"
  57. #define    CVSADM_ENTSTAT    "CVS/Entries.Static"
  58. #define    CVSADM_REP    "CVS/Repository"
  59. #define    CVSADM_CIPROG    "CVS/Checkin.prog"
  60. #define    CVSADM_UPROG    "CVS/Update.prog"
  61. #define    CVSADM_TAG    "CVS/Tag"
  62.  
  63. /*
  64.  * The following are obsolete and are maintained here only so that they can be
  65.  * cleaned up during the transition
  66.  */
  67. #define    OCVSADM        "CVS.adm"    /* for CVS 1.2 and earlier */
  68. #define    CVSADM_FILE    "CVS/Files"
  69. #define    CVSADM_MOD    "CVS/Mod"
  70.  
  71. /*
  72.  * Definitions for the CVSROOT Administrative directory and the files it
  73.  * contains.  This directory is created as a sub-directory of the $CVSROOT
  74.  * environment variable, and holds global administration information for the
  75.  * entire source repository beginning at $CVSROOT.
  76.  */
  77. #define    CVSROOTADM        "CVSROOT"
  78. #define    CVSROOTADM_MODULES    "modules"
  79. #define    CVSROOTADM_LOGINFO    "loginfo"
  80. #define    CVSROOTADM_RCSINFO    "rcsinfo"
  81. #define CVSROOTADM_COMMITINFO    "commitinfo"
  82. #define    CVSROOTADM_EDITINFO    "editinfo"
  83. #define    CVSROOTADM_HISTORY    "history"
  84. #define    CVSROOTADM_IGNORE    "cvsignore"
  85. #define CVSNULLREPOS        "Emptydir"    /* an empty directory */
  86.  
  87. /* support for the modules file (CVSROOTADM_MODULES) */
  88. #define    CVSMODULE_OPTS    "ad:i:lo:s:t:u:"/* options in modules file */
  89. #define CVSMODULE_SPEC    '&'        /* special delimiter */
  90.  
  91. /*
  92.  * The following are obsolete and are maintained here only so that they can be
  93.  * cleaned up during the transition
  94.  */
  95. #define    OCVSROOTADM        "CVSROOT.adm"    /* for CVS 1.2 and earlier */
  96.  
  97. /* Other CVS file names */
  98. #define    CVSATTIC    "Attic"
  99. #define    CVSLCK        "#cvs.lock"
  100. #define    CVSTFL        "#cvs.tfl"
  101. #define    CVSRFL        "#cvs.rfl"
  102. #define    CVSWFL        "#cvs.wfl"
  103. #define    CVSEXT_OPT    ",p"
  104. #define    CVSEXT_LOG    ",t"
  105. #define    CVSPREFIX    ",,"
  106. #define CVSDOTIGNORE    ".cvsignore"
  107.  
  108. /* miscellaneous CVS defines */
  109. #define    CVSEDITPREFIX    "CVS: "
  110. #define    CVSLCKAGE    (60*60)        /* 1-hour old lock files cleaned up */
  111. #define    CVSLCKSLEEP    30        /* wait 30 seconds before retrying */
  112. #define    CVSBRANCH    "1.1.1"        /* RCS branch used for vendor srcs */
  113. #define    BAKPREFIX    ".#"        /* when rcsmerge'ing */
  114. #define    DEVNULL        "/dev/null"
  115.  
  116. #define    FALSE        0
  117. #define    TRUE        1
  118.  
  119. /*
  120.  * Special tags. -rHEAD    refers to the head of an RCS file, regardless of any
  121.  * sticky tags. -rBASE    refers to the current revision the user has checked
  122.  * out This mimics the behaviour of RCS.
  123.  */
  124. #define    TAG_HEAD    "HEAD"
  125. #define    TAG_BASE    "BASE"
  126.  
  127. /* Environment variable used by CVS */
  128. #define    CVSREAD_ENV    "CVSREAD"    /* make files read-only */
  129. #define    CVSREAD_DFLT    FALSE        /* writable files by default */
  130.  
  131. #define    RCSBIN_ENV    "RCSBIN"    /* RCS binary directory */
  132. /* #define    RCSBIN_DFLT           Set by config.h */
  133.  
  134. #define    EDITOR_ENV    "EDITOR"    /* which editor to use */
  135. /* #define    EDITOR_DFLT           Set by config.h */
  136.  
  137. #define    CVSROOT_ENV    "CVSROOT"    /* source directory root */
  138. #define    CVSROOT_DFLT    NULL        /* No dflt; must set for checkout */
  139.  
  140. #define    IGNORE_ENV    "CVSIGNORE"    /* More files to ignore */
  141.  
  142. /*
  143.  * If the beginning of the Repository matches the following string, strip it
  144.  * so that the output to the logfile does not contain a full pathname.
  145.  * 
  146.  * If the CVSROOT environment variable is set, it overrides this define.
  147.  */
  148. #define    REPOS_STRIP    "/master/"
  149.  
  150. /*
  151.  * The maximum number of files per each CVS directory. This is mainly for
  152.  * sizing arrays statically rather than dynamically.  3000 seems plenty for
  153.  * now.
  154.  */
  155. #define    MAXFILEPERDIR    3000
  156. #define    MAXLINELEN    5000        /* max input line from a file */
  157. #define    MAXPROGLEN    30000        /* max program length to system() */
  158. #define    MAXLISTLEN    40000        /* For [A-Z]list holders */
  159. #define    MAXMESGLEN    10000        /* max RCS log message size */
  160. #define MAXDATELEN    50        /* max length for a date */
  161.  
  162. /* The type of request that is being done in do_module() */
  163. enum mtype
  164. {
  165.     CHECKOUT, TAG, PATCH
  166. };
  167.  
  168. /*
  169.  * defines for Classify_File() to determine the current state of a file.
  170.  * These are also used as types in the data field for the list we make for
  171.  * Update_Logfile in commit, import, and add.
  172.  */
  173. enum classify_type
  174. {
  175.     T_UNKNOWN = 1,            /* no old-style analog existed     */
  176.     T_CONFLICT,                /* C (conflict) list         */
  177.     T_NEEDS_MERGE,            /* G (needs merging) list     */
  178.     T_MODIFIED,                /* M (needs checked in) list      */
  179.     T_CHECKOUT,                /* O (needs checkout) list     */
  180.     T_ADDED,                /* A (added file) list         */
  181.     T_REMOVED,                /* R (removed file) list     */
  182.     T_REMOVE_ENTRY,            /* W (removed entry) list     */
  183.     T_UPTODATE,                /* File is up-to-date         */
  184.     T_TITLE                /* title for node type          */
  185. };
  186. typedef enum classify_type Ctype;
  187.  
  188. /*
  189.  * a struct vers_ts contains all the information about a file including the
  190.  * user and rcs file names, and the version checked out and the head.
  191.  * 
  192.  * this is usually obtained from a call to Version_TS which takes a tag argument
  193.  * for the RCS file if desired
  194.  */
  195. struct vers_ts
  196. {
  197.     char *vn_user;            /* rcs version user file derives from
  198.                      * it can have the following special
  199.                      * values: 
  200.                      *    empty = no user file    
  201.                      *    0 = user file is new
  202.                      *    -vers = user file to be removed */
  203.     char *vn_rcs;            /* the verion for the rcs file
  204.                      * (tag version?)      */
  205.     char *ts_user;            /* the timestamp for the user file */
  206.     char *ts_rcs;            /* the user timestamp from entries */
  207.     char *options;            /* opts from Entries file 
  208.                      * (keyword expansion)     */
  209.     char *tag;                /* tag stored in the Entries file */
  210.     char *date;                /* date stored in the Entries file */
  211.     Entnode *entdata;            /* pointer to entries file node  */
  212.     RCSNode *srcfile;            /* pointer to parsed src file info */
  213. };
  214. typedef struct vers_ts Vers_TS;
  215.  
  216. /*
  217.  * structure used for list-private storage by ParseEntries() and
  218.  * Version_TS().
  219.  */
  220. struct stickydirtag
  221. {
  222.     int aflag;
  223.     char *tag;
  224.     char *date;
  225.     char *options;
  226. };
  227.  
  228. /* flags for run_exec(), the fast system() for CVS */
  229. #define    RUN_NORMAL        0x0000    /* no special behaviour */
  230. #define    RUN_COMBINED        0x0001    /* stdout is duped to stderr */
  231. #define    RUN_REALLY        0x0002    /* do the exec, even if noexec is on */
  232. #define    RUN_STDOUT_APPEND    0x0004    /* append to stdout, don't truncate */
  233. #define    RUN_STDERR_APPEND    0x0008    /* append to stderr, don't truncate */
  234. #define    RUN_SIGIGNORE        0x0010    /* ignore interrupts for command */
  235. #define    RUN_TTY        (char *)0    /* for the benefit of lint */
  236.  
  237. /* Flags for find_{names,dirs} routines */
  238. #define W_LOCAL            0x01    /* look for files locally */
  239. #define W_REPOS            0x02    /* look for files in the repository */
  240. #define W_ATTIC            0x04    /* look for files in the attic */
  241.  
  242. /* Flags for return values of direnter procs for the recursion processor */
  243. enum direnter_type
  244. {
  245.     R_PROCESS = 1,            /* process files and maybe dirs */
  246.     R_SKIP_FILES,            /* don't process files in this dir */
  247.     R_SKIP_DIRS,            /* don't process sub-dirs */
  248.     R_SKIP_ALL                /* don't process files or dirs */
  249. };
  250. typedef enum direnter_type Dtype;
  251.  
  252. extern char *program_name, *command_name;
  253. extern char *Rcsbin, *Editor, *CVSroot;
  254. extern char *CurDir;
  255. extern int really_quiet, quiet;
  256. extern int use_editor;
  257. extern int cvswrite;
  258.  
  259. extern int trace;            /* Show all commands */
  260. extern int noexec;            /* Don't modify disk anywhere */
  261. extern int logoff;            /* Don't write history entry */
  262.  
  263. /* Externs that are included directly in the CVS sources */
  264. #if __STDC__
  265. int Reader_Lock (char *xrepository);
  266. DBM *open_module (void);
  267. FILE *Fopen (char *name, char *mode);
  268. FILE *open_file (char *name, char *mode);
  269. List *Find_Dirs (char *repository, int which);
  270. List *ParseEntries (int aflag);
  271. char *Make_Date (char *rawdate);
  272. char *Name_Repository (char *dir, char *update_dir);
  273. char *Short_Repository (char *repository);
  274. char *getcaller (void);
  275. char *time_stamp (char *file);
  276. char *xmalloc (int bytes);
  277. char *xrealloc (char *ptr, int bytes);
  278. char *xstrdup (char *str);
  279. int No_Difference (char *file, Vers_TS * vers, List * entries);
  280. int Parse_Info (char *infofile, char *repository, int (*callproc) (), int all);
  281. int Reader_Lock (char *xrepository);
  282. int SIG_register (int sig, SIGTYPE (*fn) ());
  283. int Writer_Lock (List * list);
  284. int gethostname (char *name, int namelen);
  285. int ign_name (char *name);
  286. int isdir (char *file);
  287. int isfile (char *file);
  288. int islink (char *file);
  289. int isreadable (char *file);
  290. int iswritable (char *file);
  291. int link_file (char *from, char *to);
  292. int numdots (char *s);
  293. int run_exec (char *stin, char *stout, char *sterr, int flags);
  294. int unlink_file (char *f);
  295. int update (int argc, char *argv[]);
  296. int xcmp (char *file1, char *file2);
  297. int yesno (void);
  298. time_t get_date (char *date, struct timeb *now);
  299. void Create_Admin (char *dir, char *repository, char *tag, char *date);
  300. void Lock_Cleanup (void);
  301. void ParseTag (char **tagp, char **datep);
  302. void Scratch_Entry (List * list, char *fname);
  303. void WriteTag (char *dir, char *tag, char *date);
  304. void cat_module (int status);
  305. void check_entries (char *dir);
  306. void close_module (DBM * db);
  307. void copy_file (char *from, char *to);
  308. void error (int status, int errnum, char *message,...);
  309. void fperror (FILE * fp, int status, int errnum, char *message,...);
  310. void free_names (int *pargc, char *argv[]);
  311. void freevers_ts (Vers_TS ** versp);
  312. void ign_add (char *ign, int hold);
  313. void ign_add_file (char *file, int hold);
  314. void ign_setup (void);
  315. void line2argv (int *pargc, char *argv[], char *line);
  316. void make_directories (char *name);
  317. void make_directory (char *name);
  318. void rename_file (char *from, char *to);
  319. void run_arg (char *s);
  320. void run_args (char *fmt,...);
  321. void run_print (FILE * fp);
  322. void run_setup (char *fmt,...);
  323. void strip_path (char *path);
  324. void update_delproc (Node * p);
  325. void usage (char **cpp);
  326. void xchmod (char *fname, int writable);
  327. int Checkin (int type, char *file, char *repository, char *rcs, char *rev,
  328.          char *tag, char *message, List * entries);
  329. Ctype Classify_File (char *file, char *tag, char *date, char *options,
  330.              int force_tag_match, int aflag, char *repository,
  331.              List *entries, List *srcfiles, Vers_TS **versp);
  332. List *Find_Names (char *repository, int which, int aflag,
  333.           List ** optentries);
  334. void Register (List * list, char *fname, char *vn, char *ts,
  335.            char *options, char *tag, char *date);
  336. void Update_Logfile (char *repository, char *xmessage, char *xrevision,
  337.              FILE * xlogfp, List * xchanges);
  338. Vers_TS *Version_TS (char *repository, char *options, char *tag,
  339.              char *date, char *user, int force_tag_match,
  340.              int set_time, List * entries, List * xfiles);
  341. void do_editor (char *dir, char *message, char *repository,
  342.         List * changes);
  343. int do_module (DBM * db, char *mname, enum mtype m_type, char *msg,
  344.            int (*callback_proc) (), char *where, int shorten,
  345.            int local_specified, int run_module_prog, char *extra_arg);
  346. int do_recursion (int (*xfileproc) (), int (*xfilesdoneproc) (),
  347.           Dtype (*xdirentproc) (), int (*xdirleaveproc) (),
  348.           Dtype xflags, int xwhich, int xaflag, int xreadlock,
  349.           int xdosrcs);
  350. int do_update (int argc, char *argv[], char *xoptions, char *xtag,
  351.            char *xdate, int xforce, int local, int xbuild,
  352.            int xaflag, int xprune, int xpipeout, int which,
  353.            char *xjoin_rev1, char *xjoin_rev2, char *preload_update_dir);
  354. void history_write (int type, char *update_dir, char *revs, char *name,
  355.             char *repository);
  356. int start_recursion (int (*fileproc) (), int (*filesdoneproc) (),
  357.              Dtype (*direntproc) (), int (*dirleaveproc) (),
  358.              int argc, char *argv[], int local, int which,
  359.              int aflag, int readlock, char *update_preload,
  360.              int dosrcs);
  361. void SIG_beginCrSect ();
  362. void SIG_endCrSect ();
  363. #else                /* !__STDC__ */
  364. DBM *open_module ();
  365. FILE *Fopen ();
  366. FILE *open_file ();
  367. List *Find_Dirs ();
  368. List *Find_Names ();
  369. List *ParseEntries ();
  370. Vers_TS *Version_TS ();
  371. char *Make_Date ();
  372. char *Name_Repository ();
  373. char *Short_Repository ();
  374. char *getcaller ();
  375. char *time_stamp ();
  376. char *xmalloc ();
  377. char *xrealloc ();
  378. char *xstrdup ();
  379. int Checkin ();
  380. Ctype Classify_File ();
  381. int No_Difference ();
  382. int Parse_Info ();
  383. int Reader_Lock ();
  384. int SIG_register ();
  385. int Writer_Lock ();
  386. int do_module ();
  387. int do_recursion ();
  388. int do_update ();
  389. int gethostname ();
  390. int ign_name ();
  391. int isdir ();
  392. int isfile ();
  393. int islink ();
  394. int isreadable ();
  395. int iswritable ();
  396. int link_file ();
  397. int numdots ();
  398. int run_exec ();
  399. int start_recursion ();
  400. int unlink_file ();
  401. int update ();
  402. int xcmp ();
  403. int yesno ();
  404. time_t get_date ();
  405. void Create_Admin ();
  406. void Lock_Cleanup ();
  407. void ParseTag ();
  408. void ParseTag ();
  409. void Register ();
  410. void Scratch_Entry ();
  411. void Update_Logfile ();
  412. void WriteTag ();
  413. void cat_module ();
  414. void check_entries ();
  415. void close_module ();
  416. void copy_file ();
  417. void do_editor ();
  418. void error ();
  419. void fperror ();
  420. void free_names ();
  421. void freevers_ts ();
  422. void history_write ();
  423. void ign_add ();
  424. void ign_add_file ();
  425. void ign_setup ();
  426. void line2argv ();
  427. void make_directories ();
  428. void make_directory ();
  429. void rename_file ();
  430. void run_arg ();
  431. void run_args ();
  432. void run_print ();
  433. void run_setup ();
  434. void strip_path ();
  435. void update_delproc ();
  436. void usage ();
  437. void xchmod ();
  438. void SIG_beginCrSect ();
  439. void SIG_endCrSect ();
  440. #endif                /* __STDC__ */
  441.